﻿Noi_enabletip = false;
function Noi_Tooltip() {
    document.write('<div id="div_noi_toolTip" style="visibility:hidden;left:-1000px;width:0px;background:#FFFFFF;border:1px solid #999999;padding:3px;position:absolute;"></div>');

    this.offsetfromcursorX = 12;
    this.offsetfromcursorY = 10;
    this.offsetdivfrompointerX = 10;
    this.offsetdivfrompointerY = 13;

    this.ie = document.all;
    if (!this.ie) this.ie = false; else this.ie = true;
    if (this.ie == 'undefined') this.ie = false; else this.ie = true;

    this.ns6 = document.getElementById && !document.all;
    if (!this.ns6) this.ns6 = false; else this.ns6 = true;
    if (this.ns6 == 'undefined') this.ns6 = false; else this.ns6 = true;

    this.ietruebody = function () {
        return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
    };

    this.showtip = function (show, thetext) {
        $("div_noi_toolTip").innerHTML = "<img src='" + thetext + "' />";
        Noi_enabletip = true;
    };

    this.positiontip = function (e) {
        if (Noi_enabletip) {

            this.offsetfromcursorX = 12;
            this.offsetfromcursorY = 10;
            this.offsetdivfrompointerX = 10;
            this.offsetdivfrompointerY = 13;

            this.ie = document.all;
            if (this.ie == 'undefined') this.ie = false;
            if (this.ie) this.ie = true; else this.ie = false;

            this.ns6 = document.getElementById && !document.all;


            var nondefaultpos = false;

            var curX = (this.ns6) ? e.pageX : event.clientX + NoiTip.ietruebody().scrollLeft;
            var curY = (this.ns6) ? e.pageY : event.clientY + NoiTip.ietruebody().scrollTop;

            var winwidth = this.ie && !window.opera ? NoiTip.ietruebody().clientWidth : window.innerWidth - 20;
            var winheight = this.ie && !window.opera ? NoiTip.ietruebody().clientHeight : window.innerHeight - 20;
            var rightedge = this.ie && !window.opera ? winwidth - event.clientX - this.offsetfromcursorX : winwidth - e.clientX - this.offsetfromcursorX;
            var bottomedge = this.ie && !window.opera ? winheight - event.clientY - this.offsetfromcursorY : winheight - e.clientY - this.offsetfromcursorY;
            var leftedge = (this.offsetfromcursorX < 0) ? this.offsetfromcursorX * (-1) : -1000;


            if (rightedge < $("div_noi_toolTip").offsetWidth) {
                $("div_noi_toolTip").style.left = curX - $("div_noi_toolTip").offsetWidth + "px";
                nondefaultpos = true;
            }
            else if (curX < leftedge)
                $("div_noi_toolTip").style.left = "5px";
            else {
                $("div_noi_toolTip").style.left = curX + this.offsetfromcursorX - this.offsetdivfrompointerX + "px";
            }



            if (bottomedge < $("div_noi_toolTip").offsetHeight) {
                $("div_noi_toolTip").style.top = curY - $("div_noi_toolTip").offsetHeight - this.offsetfromcursorY + "px";
                nondefaultpos = true;
            }
            else {
                $("div_noi_toolTip").style.top = curY + this.offsetfromcursorY + this.offsetdivfrompointerY + "px";
            }

            $("div_noi_toolTip").style.visibility = "visible";
        }

    };
    this.hidetip = function () {
        Noi_enabletip = false;
        $("div_noi_toolTip").style.visibility = "hidden";
        $("div_noi_toolTip").style.left = "-1000px";
        $("div_noi_toolTip").style.width = '';
    };

    this.addMouseHandlers = function () {
        if (window.addEventListener) {		// Firefox/Opera
            window.addEventListener("mouseover", this.positiontip, false);
        } else if (document.attachEvent) {	// IE
            document.attachEvent("onmouseover", this.positiontip);
        } else {
            window.onmouseover = document.onmouseover = this.positiontip; // other browsers
        }
    };
}

var NoiTip = new Noi_Tooltip();
NoiTip.addMouseHandlers();